package 网络通信;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class 接收端 {
    public static void main(String[] args) throws IOException {
        byte[] buff=new byte[1024];
        DatagramSocket ds=new DatagramSocket(6666);
        DatagramPacket dp=new DatagramPacket(buff,buff.length);
        System.out.println("等待数据—-----");
        ds.receive(dp);

        String str=new String(dp.getData(),0,dp.getLength())
                +" "+dp.getAddress().getHostAddress()+":"+dp.getPort();
        System.out.println(str);
        ds.close();

    }
}
